cssstaticstyle: Move function
authorBenjamin Otte <otte@redhat.com>
Wed, 17 Dec 2014 04:52:13 +0000 (05:52 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 7 Jan 2015 13:26:47 +0000 (14:26 +0100)
We want the new() return values to be immutable, so we have to move the
code that modifes them.

gtk/gtkcssstaticstyle.c
gtk/gtkcssstaticstyleprivate.h
gtk/gtkstylecontext.c

index 82066cf1f0a48b69260cdf9219da42803aed8ff6..2819fdb6e192525f5665b5aa0fdef6eca20afee7 100644 (file)
@@ -177,9 +177,34 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *style,
 }
 
 GtkCssStyle *
-gtk_css_static_style_new (void)
+gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
+                                  const GtkCssMatcher     *matcher,
+                                  int                      scale,
+                                  GtkCssStyle             *parent,
+                                  GtkCssChange            *out_change)
 {
-  return g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
+  GtkCssStaticStyle *result;
+  GtkCssLookup *lookup;
+
+  lookup = _gtk_css_lookup_new (NULL);
+
+  if (matcher)
+    _gtk_style_provider_private_lookup (provider,
+                                        matcher,
+                                        lookup,
+                                        out_change);
+
+  result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
+
+  _gtk_css_lookup_resolve (lookup, 
+                           provider,
+                          scale,
+                           result,
+                           parent);
+
+  _gtk_css_lookup_free (lookup);
+
+  return GTK_CSS_STYLE (result);
 }
 
 GtkCssStyle *
index a18127bc223a6720a65b311cb74f086f91af794b..09e28189c8d23b6a282ea06c001a8599cb7856a9 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __GTK_CSS_STATIC_STYLE_PRIVATE_H__
 #define __GTK_CSS_STATIC_STYLE_PRIVATE_H__
 
+#include "gtk/gtkcssmatcherprivate.h"
 #include "gtk/gtkcssstyleprivate.h"
 
 G_BEGIN_DECLS
@@ -54,7 +55,11 @@ struct _GtkCssStaticStyleClass
 
 GType                   gtk_css_static_style_get_type           (void) G_GNUC_CONST;
 
-GtkCssStyle *           gtk_css_static_style_new                (void);
+GtkCssStyle *           gtk_css_static_style_new_compute        (GtkStyleProviderPrivate *provider,
+                                                                 const GtkCssMatcher    *matcher,
+                                                                 int                     scale,
+                                                                 GtkCssStyle            *parent,
+                                                                 GtkCssChange           *out_change);
 GtkCssStyle *           gtk_css_static_style_copy               (GtkCssStaticStyle *original,
                                                                  const GtkBitmask  *properties_to_not_copy);
 
index 69722a21a8b5ab47840927069e7d59fb668a14ed..ba62c1b581ef9a806d896eb117e5134bfb926459 100644 (file)
@@ -734,29 +734,25 @@ build_properties (GtkStyleContext             *context,
   GtkStyleContextPrivate *priv;
   GtkCssMatcher matcher;
   GtkWidgetPath *path;
-  GtkCssLookup *lookup;
   GtkCssStyle *style;
 
   priv = context->priv;
 
-  style = gtk_css_static_style_new ();
-
   path = create_query_path (context, decl);
-  lookup = _gtk_css_lookup_new (NULL);
 
   if (_gtk_css_matcher_init (&matcher, path))
-    _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
-                                        &matcher,
-                                        lookup,
-                                        out_change);
-
-  _gtk_css_lookup_resolve (lookup, 
-                           GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
-                          priv->scale,
-                           GTK_CSS_STATIC_STYLE (style),
-                           priv->parent ? style_values_lookup (priv->parent) : NULL);
+    style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+                                              &matcher,
+                                              priv->scale,
+                                              priv->parent ? style_values_lookup (priv->parent) : NULL,
+                                              out_change);
+  else
+    style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+                                              NULL,
+                                              priv->scale,
+                                              priv->parent ? style_values_lookup (priv->parent) : NULL,
+                                              out_change);
 
-  _gtk_css_lookup_free (lookup);
   gtk_widget_path_free (path);
 
   return style;